package com.javasm.bootcrud01.config;

import com.javasm.bootcrud01.config.interceptor.LoginInterceptor;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;


@Component
public class WebConfig implements WebMvcConfigurer {


    @Resource
    LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                //拦截所有页面
                .addPathPatterns("/**")
                //排除不拦截的路径
                .excludePathPatterns("/user/info/**");
    }
}
